package com.example.learn.controller;

import com.example.learn.pojo.Plans;
import com.example.learn.pojo.Quadrant;
import com.example.learn.service.PlanService;
import com.example.learn.service.QuadrantService;
import com.example.learn.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/quadrant")
public class QuadrantController {

    @Autowired
    QuadrantService quadService;

    @RequestMapping("/list")
    public R<Map> getPlanList() {
        List<Quadrant> quadList = quadService.getQuadList();
        Map dataMap = new HashMap();
        dataMap.put("data", quadList);
        return R.success(dataMap,"success");
    }

    @PostMapping("/update")
    public R updatePlan(@RequestBody Quadrant quadrant) {
        int count = quadService.updateQuadrant(quadrant);
        if(count >= 1){
            return R.success("修改成功");
        }else {
            return R.failed("修改失败");
        }
    }
}
